import app from '@/app'

export class BudgetViewModel {
    budgetName: string = ""
    budgetAmount: number = 0
    budgetUsage: string = ""
    useTime: string = app.DATE_EMPTY

    constructor (budgetName: string , budgetAmount: number, budgetUsage: string, useTime: string) {
        this.budgetName = budgetName;
        this.budgetAmount = budgetAmount;
        this.budgetUsage = budgetUsage;
        this.useTime = useTime;
    }

    static fromModel (model : Budget[]) : BudgetViewModel[] {
        const result : BudgetViewModel[] = model.map((item => 
            new BudgetViewModel(item.BudgetName, item.BudgetAmount, item.BudgetUsage, item.UseTime)
        ));
        return result;
    }
}

export interface Budget {
    ID: string,
    ProjectId: string,
    DisplayOrder: number,
    BudgetAmount: number,
    BudgetName: string,
    BudgetUsage: string,
    UseTime: string,
}

export const emptyMemberViewModel : BudgetViewModel = {
    budgetName: "",
    budgetAmount: 0,
    budgetUsage: "",
    useTime: "",
};